package com.qtummatrix.controller;

import com.opensymphony.xwork2.ActionSupport;
import com.qtummatrix.service.AuthotityManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

/**
 * create by Gongshiyong  2019-11-28 11:19
 */

/**
 * 实现修改密码和退出登录操作
 */
@Controller("eidtUserAction")
public class EidtUserController extends ActionSupport {

    //设置前端传过来值对应的字段，生成get、set方法
    private String tel;
    private String oldPassword;
    private String newPassword;

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getOldPassword() {
        return oldPassword;
    }

    public void setOldPassword(String oldPassword) {
        this.oldPassword = oldPassword;
    }

    public String getNewPassword() {
        return newPassword;
    }

    public void setNewPassword(String newPassword) {
        this.newPassword = newPassword;
    }

    @Autowired
    private AuthotityManagerService authotityManagerService;

    private Map<String, Object> info = new HashMap<String, Object>();

    public Map<String, Object> getInfo() {
        return info;
    }

    public void setInfo(Map<String, Object> info) {
        this.info = info;
    }

    /**
     * 修改密码
     *
     * @return
     */
    public String updatePassword() {
        String tel = getTel();
        String oldPassword = getOldPassword();
        String newPassword = getNewPassword();
        String str = authotityManagerService.eidtPassword(tel, oldPassword, newPassword);
        info.put("eidtPasswordResult", str);
        return SUCCESS;
    }


}
